package com.woniu.smart.service.impl;

import com.github.pagehelper.PageHelper;
import com.woniu.smart.dto.VisitorAccDTO;
import com.woniu.smart.dto.VisitorDTO;
import com.woniu.smart.entity.Access;
import com.woniu.smart.entity.Car;
import com.woniu.smart.entity.Visitor;
import com.woniu.smart.mapper.AccessMapper;
import com.woniu.smart.mapper.CarMapper;
import com.woniu.smart.mapper.VisitorMapper;
import com.woniu.smart.service.VisitorService;
import com.woniu.smart.vo.SelByNameVisitorVO;
import com.woniu.smart.vo.VistorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ：zhuboyuan
 * @date ：Created in 2022/10/20 23:16
 * @description：c{description}
 * @modified By：
 * @version: $
 */
@Service
public class VisitorServiceImpl implements VisitorService {
    @Autowired
    private VisitorMapper visitorMapper;
    @Autowired
    private AccessMapper accessMapper;



    @Override
    public List<VistorVo> selectByAll(VisitorDTO visitorDTO) { return visitorMapper.selectByAll(visitorDTO); }

    @Override
    public List<VistorVo> selectAccess(VisitorDTO visitorDTO) { return visitorMapper.selectAccess(visitorDTO); }

    @Override
    public VistorVo selectById(Long id) { return visitorMapper.selectById(id); }

    @Override
    public SelByNameVisitorVO selByNameVisitor(VisitorAccDTO visitorAccDTO) {
        return visitorMapper.selByNameVisitor(visitorAccDTO);
    }

    @Override
    public Long selectPageNums(VisitorDTO visitorDTO) { return visitorMapper.selectPageNums(visitorDTO); }

    @Override
    public int deleteById(Long id) {
        return visitorMapper.deleteById(id);
    }

    @Override
    public int deleteBatch(List<Integer> visitorIds) {
        return visitorMapper.deleteBatch(visitorIds);
    }

    @Override
    @Transactional
    public int insert(Visitor visitor) {
        return visitorMapper.insert(visitor);
    }

    @Override
    public int insertSelective(Visitor record) {return visitorMapper.insertSelective(record); }

    @Override
    @Transactional
    public int insertNewSelective(VisitorAccDTO visitorAccDTO) {
        int insert = visitorMapper.insertNewSelective(visitorAccDTO);
        int insert1 = accessMapper.insertNewSelective(visitorAccDTO);
        return 1;
    }

    @Override
    public Visitor selectByPrimaryKey(Long id) {
        return visitorMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Visitor record) {
        return visitorMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Visitor record) {
        return visitorMapper.updateByPrimaryKey(record);
    }
}

